<?php

require_once 'Basic.php';

class FormFieldTextLine extends FormFieldType {

  private $nonempty;
  
  public function __construct($nonempty = false) {
    $this->nonempty = $nonempty;
    $this->htmlId = null;
    $this->inputSize = 30;
    $this->htmlClass = "textlineField";
  }
  
  public function getHtml($name, $value = null) {
    return $this->commonHtml($name,$value);
  }
  
  public function validate($input) {
    if($this->nonempty && strlen($input) !== 0) {
      return true;
    }
    else if($this->nonempty) {
      return "A entrada n&atilde;o pode ser vazia.";
    }
    else {
      return true;
    }
  }
  
  public function clearHtmlClass() {
    $this->htmlClass = "textlineField";
  }
  
}
